package cn.gmph.blog.admin.service.sys;

import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.gmph.blog.admin.service.sys.dao.UsersDAO;
import cn.gmph.blog.admin.service.sys.entity.UsersDO;
import cn.gmph.core.base.BaseService;
import cn.gmph.core.base.ResultDTO;
import cn.gmph.core.base.ResultPageDTO;

@Service
public class UsersService extends BaseService {

 private Logger logger = LoggerFactory.getLogger(this.getClass());
 @Autowired
 private UsersDAO usersDAO;

 // 分页
 public ResultPageDTO<UsersDO> page(UsersDO users, Integer pageNum, Integer pageSize) {
     logger.info("开始分页查询UsersService.page, users=" + users.toString());
     List<UsersDO> pageList = this.usersDAO.pageList(users, pageNum, pageSize);
     Integer count = this.usersDAO.pageListCount(users);
   ResultPageDTO<UsersDO> pager =  new ResultPageDTO<UsersDO>(count,pageList);
     return pager;
 }

 // 添加
 public UsersDO doAdd (UsersDO users,int loginUserId) {
     logger.info("开始添加UsersService.add,users=" + users.toString());
     this.usersDAO.insert(users);
     return users;
 }

 // 修改
 public Integer doUpdate (UsersDO users,Integer loginUserId) {
     logger.info("开始修改UsersService.update,users=" + users.toString());
     int rows=this.usersDAO.update(users);
     return rows;
 }

 // 删除
 public Integer doDelete (UsersDO users,Integer loginUserId) {
     logger.info("开始删除UsersService.delete,users=" + users.toString());
     int rows=this.usersDAO.deleteById(users.getId());
     return rows;
 }

 // 查询
 public UsersDO doQueryById (Integer id) {
     UsersDO obj = this.usersDAO.getById(id);
     return obj;
 }
}